/*
 * @Date: 2020-08-26 15:06:54
 * @LastEditors: xujianxing
 * @LastEditTime: 2020-08-26 15:10:34
 * @FilePath: \nili\src\common\anotation\token.ano.ts
 */
import { createParamDecorator, ExecutionContext } from '@nestjs/common';

// 参数装饰器，从 request 中拿到 token 属性
export const Token = createParamDecorator(
  (data: unknown, ctx: ExecutionContext) => {
    const request = ctx.switchToHttp().getRequest();
    const headers = request.headers;
    return headers['token'];
  },
);
